//
//  SelectedController.m
//  EagleEye
//
//  Created by 18_李明明 on 15-1-28.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "SelectedController.h"
#import "DataBaseHandler.h"
#import "QRSelectController.h"
#import "ExpressSelectController.h"
#import "BusSelectController.h"
#import "TrainSelectController.h"
#import "PhoneSelectViewController.h"
@interface SelectedController ()<UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) DataBaseHandler *dataBase;
@property (nonatomic, strong) UITableView *allFunction;
@property (nonatomic, strong) NSArray *functionArr;
@end

@implementation SelectedController
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.functionArr = [NSArray arrayWithObjects:@"二维码/条形码", @"快递", @"公交", @"火车", @"归属地", nil];
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"查询历史";
    self.dataBase = [DataBaseHandler shareInstance];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    // 创建tableveiw
    self.allFunction = [[UITableView alloc] initWithFrame:CGRectMake(0, -35, WIDTH, HEIGHT - 24) style:UITableViewStyleGrouped];
    [self.view addSubview:self.allFunction];
    self.allFunction.delegate = self;
    self.allFunction.dataSource = self;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
//
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"0502"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"0502"];
    }
    cell.textLabel.text = [self.functionArr objectAtIndex:indexPath.row];
    return cell;
}
// 点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        QRSelectController *qrselectVC = [[QRSelectController alloc] init];
        [self.navigationController pushViewController:qrselectVC animated:YES];
    }else if (indexPath.row == 1) {
        ExpressSelectController *expressVC = [[ExpressSelectController alloc] init];
        [self.navigationController pushViewController:expressVC animated:YES];
    }else if (indexPath.row == 2) {
        BusSelectController *busVC = [[BusSelectController alloc] init];
        [self.navigationController pushViewController:busVC animated:YES];
    }else if (indexPath.row == 3) {
        TrainSelectController *trainVC = [[TrainSelectController alloc] init];
        [self.navigationController pushViewController:trainVC animated:YES];
    }else {
        PhoneSelectViewController *phoneVC = [[PhoneSelectViewController alloc] init];
        [self.navigationController pushViewController:phoneVC animated:YES];
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
